home *** CD-ROM | disk | FTP | other *** search
/ Shareware Super Platinum 8 / Shareware Super Platinum 8.iso / mac / PROGTOOL / XRAY.ZIP;1 / XRAY.EXE / XRAY.DOC < prev   
Encoding:
Text File  |  1989-09-13  |  16.7 KB  |  394 lines

  1. XRAY  by Tom Kihlken
  2. Version 1.2 - September 1989
  3.  
  4.  
  5.   XRAY is a DOS programming tool which displays informative messages about 
  6. the operating system functions.  With XRAY, you'll be able to snoop in on 
  7. the operating systems inards and diagnose obscure programming bugs.  It 
  8. can be used with programs written in any language and requires no special 
  9. compiler.  It also includes a high resolution timer to help optimize your 
  10. program's I/O.
  11.  
  12.   This program is shareware.  Shareware allows you to try the program out 
  13. before you buy it.  You may also make copies for your friends or post it 
  14. on another BBS.  If you like the program and want to continue using it, 
  15. you must register by sending your name, address, $15, and the version 
  16. number shown above to the following address.  You may purchase a copy of 
  17. the assembler language source code for $30.  Your support of shareware 
  18. insures continued development of good low cost software.
  19.  
  20. Tom Kihlken
  21. 3665 McKibbon Road
  22. Saint Louis, Missouri 63114
  23.  
  24.  
  25.  
  26.   XRAY is a memory resident program which provides a detailed report of 
  27. exactly what DOS functins (including lots of undocumented ones) your 
  28. program is making.  Whether your use it to snoop, or to monitor you system 
  29. as it crashes, you're bound to see some surprises.  Also included is a 
  30. high resolution timer which helps detect I/O bound code which can bog down 
  31. even the tightest assembler program.
  32.   If your a programmer, use XRAY to check that your program is working 
  33. properly (or discover why it's crashing!).  Of course it's just as easy to 
  34. spy on someone elses code to learn how it works.  You'll be able to see 
  35. how data base files are updated and even how some copy protection 
  36. techniques work!
  37.   XRAY works by intercepting interrupt 21h.  Each DOS function call 
  38. outputs a single line of information.  The first two items on the line are 
  39. the function number and a brief description of it (Appendix A shows a 
  40. complete list of the DOS functions).  Next, you will find any important 
  41. input parameters, such as file names, handles, buffer sizes, etc.  
  42.   Next, the actual function is performed.  If the /T option was specified, 
  43. its elapsed time is shown (accurate to 0.0001 seconds).  If the function 
  44. returns information (like a filename, directory, etc.), that is shown next.  
  45. Finally, either a descriptive error message or "OK" is output to indicate 
  46. the result of the operation.
  47.  
  48.   You may run XRAY as many times as you like to change the options.  To 
  49. restore the defaults, just uninstall (/U) XRAY and then reinstall it.  
  50. Here is a complete list of the parameters.
  51.  
  52. XRAY  [/C] [/Dn-m] [/F] [/H] [/In-m] [/J] [/Kn] [/O] [/Pn] [/Sn] [/T] [/U] [/V]
  53.  
  54. Where:
  55.  
  56.    /C = Send output to the console (this is the default mode).
  57.         The BIOS write TTY video function is used to display characters.
  58.  
  59. /Dn-m = Display DOS function calls numbered betweem n and m (n and m are 
  60.         entered in hex).  The default is to display functions numbered 
  61.         0Ch and above.  By displaying only selected functions you can 
  62.         minimize the amount of output XRAY produces. You may repeat the
  63.         /D (and /I) parameter to display several ranges.
  64.  
  65.    /F = Send output to a disk file (the default is to display the output 
  66.         on the screen).  When /D is specified, all output is internally 
  67.         buffered in a 1K buffer.  The default filename is is 
  68.         C:\XRAY.LOG.  It may be changed in the .COM file with DEBUG. 
  69.         The maximum length should be 80 characters.
  70.  
  71.    /H = Display the meaning of the optional parameters.
  72.  
  73.    /J = Causes XRAY to JMP to the original interrupt address rather than
  74.         CALLing it.  This causes the XRAY to be less obtrusive, so give
  75.     it a try if your program doesn't run normally without it.  If you
  76.     use the /J option, you won't be able to see the result code or 
  77.     the elapsed time of the call however.
  78.  
  79. /In-m = Ignore DOS function calls numbered between n and m (n and m are 
  80.         entered in hex).  The default is to ignore functions numbered 
  81.         0Bh and below.  By ignoring low numbered functions XRAY 
  82.         produces less output and your program will run faster. You may 
  83.         repeat the /I (and /D) parameter to ignore several ranges.
  84.  
  85.   /Kn = Use Scan code n (n is entered in hex) for the Hot key.  You can 
  86.         press ALT and the hot key to toggle XRAYs output ON and OFF. 
  87.         The default is to not use a hot-key (for maximum keyboard 
  88.         compatiblity).  See appendix B for a table of scan codes.
  89.  
  90.     Note:  You must use the /K parameter the very first time you 
  91.     install XRAY to make the hot key to work.  This allows you to
  92.     prevent the keyboard interrupt vector from being redirected if
  93.     you don't use the hot key option.
  94.  
  95.    /O = Turns XRAY OFF.  You may turn it back on with either the hot 
  96.         key or by running it again from the command prompt.
  97.  
  98.   /Pn = Send output to LPTn (n is entered in hex).  The default is to 
  99.         display its output on the screen.  The printer is the best 
  100.         real-time output option since it is available up to the time of 
  101.         a system crash.
  102.  
  103.   /Sn = Use the shift state n (n is entered in hex) with the hot key to
  104.         toggle XRAYs output ON and OFF.  The default value is 8 which is
  105.         to press Alt with the hot key.  See appendix C for a table of shift
  106.         state values.
  107.  
  108.    /T = Display elapsed Time of each DOS call your program makes. It is 
  109.         useful to optimize programs which are I/O intensive.  The 
  110.         elapsed time of each call to DOS is reported to the nearest 
  111.         .0001 second.  Functions which require more than about 64
  112.         seconds will not be correctly reported (this is rare).  
  113.  
  114.    /U = Uninstall XRAY from memory (if possible).  XRAY can only be 
  115.     uninstalled if no other TSR programs (which use interrupts 9 or
  116.     21h) have been loaded.
  117.  
  118.    /V = Display function calls made by COMMAND.COM.  The default is to 
  119.         ignore these calls.  If you use the /C option, XRAY will 
  120.         produce lots of output which may not be of interest for your 
  121.         application but it's facinating to see how the command interpreter
  122.         does its thing.  When you use /V, calls from COMMAND.COM are 
  123.     marked with an asterick.
  124.  
  125.  
  126.  
  127. OUTPUT OPTIONS
  128.  
  129.   The output from XRAY is sent to either the screen, printer, or a disk 
  130. file.  Which one you choose depends on what you are using it for.  
  131.   The screen is the easiest since it is fast and you can watch it easily.  
  132. Unfortunately, it usually makes a mess of the overlying applications video 
  133. output.  XRAY uses the BIOS write TTY function to drive the display.
  134.   Sending the output to a file is better for large amounts of output.  The 
  135. disadvantage of using a file is that some output is lost in the event of a 
  136. system crash due to internal buffering.  The size of this buffer is 1K 
  137. (about 20 function calls).  
  138.   The filename is C:\XRAY.LOG, but you may change it in the .COM file 
  139. using DEBUG or a binary file editor.  There is space for a maximum of 
  140. about 80 characters in the name.
  141.   The printer is the best output method for observing a system crash since 
  142. all of the output is displayed, right up until the machine locks up.  
  143. Printing will slow down your program however and in some cases may cause 
  144. time critical programs to timeout.  XRAY uses the BIOS print character 
  145. function to drive the printer.
  146.  
  147.  
  148.  
  149. ELAPSED TIME MEASUREMENT
  150.  
  151.   XRAY uses the 8253 timer/counter to measure elapsed time of DOS function 
  152. calls.  This counter is calibrated as part of the installation process to 
  153. show only the acural time executing DOS code and is accurate to within 
  154. approximately 10 microseconds (times are displayed to the nearest .1 
  155. millisecond).  Since a 16 bit word is used to hold the time, values 
  156. greater than 64 seconds will be in error.  This shouldn't be a problem 
  157. since most functions are completed is a second or less.
  158.   When the timer option is selected, the 8253 (timer 0) is reprogrammed to 
  159. mode 2 (divide by n) on every DOS call.  This won't affect the clock tick 
  160. rate, however it can cause a few extra ticks which make the system clock 
  161. seem run a bit fast.  If you're concerned about restoring the time after 
  162. running XRAY, you should reboot the machine.
  163.  
  164.  
  165.  
  166. SELECTING FUNCTIONS
  167.  
  168.   Most programs make lots of calls to the operating system.  When this 
  169. happens, XRAY produces lots of output if you don't suppress some of it. An 
  170. example of this is when a program continuously reads the clock in order to 
  171. display the time on screen.  It is easy to filter out this uninteresting 
  172. stuff with XRAY, using the /D (Display)) and /I (Ignore) options.
  173.   The default setting for the filter is to ignore functions numbered lower 
  174. than 0Ch.  To ignore additional functions, just use the /In-m option.  To 
  175. add functions to the filter, use /Dn-m.  You can specify as many ranges as 
  176. you like.  You can also specify a single function number such as /I2C.  
  177.   As each range is parsed from the command tail, it takes precedence over 
  178. previouw ranges, so the order in which you specify them controls how they 
  179. are combined.  Remember, you always start with the default filter (or the 
  180. existing filter if XRAY has already been installed).
  181.   Let's look at an example.  Say we're interested in the functions 3Ch to 
  182. 40h, 16h to 17h, and 4C.  The correct parameters would be:
  183.  
  184.        /I0-FF /D16-17 /D3C-40 /D4C
  185.  
  186.   Notice the first "/I" turned off everything, the next three "/D's" turn 
  187. on the ranges we want.  When selecting ranges, it's best to avoid the 
  188. console I/O functions (01h through 0Bh) since there are millions of them 
  189. in most programs.
  190.  
  191.  
  192.  
  193. USING A HOT KEY
  194.  
  195.   Normally XRAY does its job continously after installed.  You can switch 
  196. XRAY off by running it again with the /O option.  An easier method is to 
  197. specify a hot key which will toggle XRAY off and on.
  198.   To enable use of a hot key, you MUST specify a scan code (with the /K 
  199. parameter) during the initial installation.  The default scan code is 0FFh 
  200. which indicates that the keyboard interrupt vector is not to be 
  201. intercepted and the hot key is disabled.  You can change the scan code 
  202. later if you want but you MUST enable it the FIRST time XRAY is installed.
  203.   Scan codes are selected from appendix B.  You must hold down the Alt key 
  204. together with the selected hot key.  If you want some other shift key, 
  205. specify a shift mask with the /S option.  Valid shift codes are shown in 
  206. appendix C.
  207.  
  208.  
  209.  
  210. A NOTE ABOUT COMPATIBILITY
  211.  
  212.   XRAY was written to be as compatible as possible with most programs.  
  213. Like all TSR's however, there will always be some programs which may not 
  214. run correctly with it installed.  If you seem to have trouble, there are a 
  215. couple things you can try.  
  216.   First of all, remove any other TSR programs you are using (or load them 
  217. in a different order).  Second, If the hot key interfers with your 
  218. application, try a different scan code or reinstall XRAY with the hot key 
  219. disabled (by not using a scan code).  
  220.   Third, try the /J option.  This causes XRAY to JMP to the original 
  221. interrupt 21 address rather than CALLing it, makint it less obtrusive.  
  222. When you do this however, you won't be able to see the result code or the 
  223. elapsed time of the call however.
  224.  
  225.  
  226.  
  227. DIGGING DEEPER
  228.  
  229.   After spending a little time with XRAY, you're bound to see things 
  230. you've never heard of or don't understand.  I can't possibly explain 
  231. everything about DOS, I'll recommend a couple good books on the subject.
  232.  
  233.    Duncan, Ray. Advanced MS-DOS.  Redmond, Redmond, Wash.: Microsoft 
  234.     Corporation, 1986.
  235.  
  236.    Lafore, Robert. Assembly Language Primer for the IBM PC&XT.
  237.     New York: Plume/Waite, 1984.
  238.  
  239.    Scanlon, Leo J. IBM PC Assembly Language: A Guide for Programmers.
  240.     Bovie, Md.: Robert J. Brady Co. 1983.
  241.  
  242.  
  243.  
  244. Appendix A
  245. DOS FUNCTION CALLS
  246.  
  247.     00h - TERMINATE PROCEDURE
  248.     01h - READ KEYBOARD WITH ECHO
  249.     02h - DISPLAY CHARACTER
  250.     03h - AUXILARY INPUT
  251.     04h - AUXILARY OUTPUT
  252.     05h - PRINT CHARACTER
  253.     06h - DIRECT CONSOLE I/O
  254.     07h - DIRECT CONSOLE INPUT
  255.     08h - READ KEYBOARD
  256.     09h - DISPLAY STRING
  257.     0Ah - BUFFERED KEYBOARD INPUT
  258.     0Bh - CHECK KEYBOARD STATUS
  259.     0Ch - FLUSH KEYBOARD BUFFER
  260.     0Dh - DISK RESET
  261.     0Eh - SELECT DEFAULT DISK
  262.     0Fh - OPEN FILE (FCB)
  263.     10h - CLOSE FILE (FCB)
  264.     11h - SEARCH FOR FIRST FILE (FCB)
  265.     12h - SEARCH FOR NEXT FILE (FCB)
  266.     13h - DELETE FILE (FCB)
  267.     14h - SEQUENTIAL READ (FCB)
  268.     15h - SEQUENTIAL WRITE (FCB)
  269.     16h - CREATE FILE (FCB)
  270.     17h - RENAME FILE (FCB)
  271.     19h - GET CURRENT DISK
  272.     1Ah - SET DISK TRANSFER ADDRESS
  273.     1Bh - GET ALLOCATION TABLE INFO FOR DEFAULT DRIVE
  274.     1Ch - GET ALLOCATION TABLE INFO FOR SPECIFIED DRIVE
  275.     21h - RANDOM READ (FCB)
  276.     22h - RANDOM WRITE (FCB)
  277.     23h - FILE SIZE (FCB)
  278.     24h - SET RELATIVE RECORD (FCB)
  279.     25h - SET VECTOR
  280.     26h - CREATE NEW PROGRAM SEGMENT
  281.     27h - RANDOM BLOCK READ (FCB)
  282.     28h - RANDOM BLOCK WRITE (FCB)
  283.     29h - PARSE FILENAME (FCB)
  284.     2Ah - GET DATE
  285.     2Bh - SET DATE
  286.     2Ch - GET TIME
  287.     2Dh - SET TIME
  288.     2Eh - SET/RESET VERIFY FLAG
  289.     2Fh - GET DATA TRANSFER AREA
  290.     30h - GET DOS VERSION NUMBER
  291.     31h - KEEP PROCESS
  292.     33h - CONTRL BREAK CHECK
  293.     34h - GET BUSY FLAG
  294.     35h - GET VECTOR
  295.     36h - GET DISK FREE SPACE
  296.     38h - GET/SET COUNTRY INFORMATION
  297.     39h - MAKE DIRECTORY
  298.     3Ah - REMOVE DIRECTORY
  299.     3Bh - CHANGE DIRECTORY
  300.     3Ch - CREATE FILE
  301.     3Dh - OPEN FILE HANDLE
  302.     3Eh - CLOSE FILE HANDLE
  303.     3Fh - READ FROM FILE/DEVICE
  304.     40h - WRITE TO A FILE/DEVICE
  305.     41h - DELETE FILE
  306.     42h - MOVE POINTER
  307.     43h - CHANGE FILE ATTRIBUTE
  308.     44h - I/O CONTROL FOR DEVICES
  309.     45h - DUPLICATE FILE HANDLE
  310.     46h - FORCE DUPLICATE FILE HANDLE
  311.     47h - GET CURRENT DIRECTORY
  312.     48h - ALLOCATE MEMORY
  313.     49h - FREE MEMORY
  314.     4Ah - MODIFY MEMORY BLOCK
  315.     4Bh - EXECUTE A PROGRAM
  316.     4Ch - TERMINATE PROGRAM
  317.     4Dh - RETRIEVE THE RETURN CODE OF A CHILD
  318.     4Eh - FIND FIRST MATCHING FILE
  319.     4Fh - FIND NEXT MATCHING FILE
  320.     50h - SET PROGRAM SEGMENT PREFIX
  321.     51h - GET PROGRAM SEGMENT PREFIX
  322.     54h - GET VERIFY SETTING
  323.     56h - RENAME A FILE
  324.     57h - GET/SET FILE DATE
  325.     59h - GET EXTENDED ERROR
  326.     5Ah - CREATE UNIQUE FILE
  327.     5Bh - CREATE NEW FILE
  328.     5Ch - LOCK/UNLOCK FILE ACCESS
  329.     5Eh - PRINTER SETUP
  330.     5Fh - DEVICE REDIRECTION FUNCTIONS
  331.     61h - SET PROGRAM SEGMENT PREFIX
  332.     62h - GET PROGRAM SEGMENT PREFIX
  333.  
  334.     
  335.  
  336. Appendix B
  337. KEYBOARD SCAN CODES
  338.  
  339.   The following is a partial list of values which can used with the /K 
  340. option to specify a hot key scan code.  The keys which are described as 
  341. "KP" are on the numeric keypad on the right side of the keyboard.  Other 
  342. codes can be found in any good technical reference.
  343.   The default condition is for the hot key to be disabled.
  344.  
  345. Code   Key             Code   Key              Code     Key
  346.  
  347.  1Eh     A              01h   Esc              3Bh       F1
  348.  30h     B              02h     1              3Ch       F2
  349.  2Eh     C              03h     2              3Dh       F3
  350.  20h     D              04h     3              3Eh       F4
  351.  12h     E              05h     4              3Fh       F5
  352.  21h     F              06h     5              40h       F6
  353.  22h     G              07h     6              41h       F7
  354.  23h     H              08h     7              42h       F8
  355.  17h     I              09h     8              43h       F9
  356.  24h     J              0Ah     9              44h      F10
  357.  25h     K              0Bh     0              57h      F11
  358.  26h     L              0Ch     -              58h      F12
  359.  32h     M              0Dh     =              47h      KP7
  360.  31h     N              0Eh    BS              48h      KP8
  361.  18h     O              0Fh   TAB              49h      KP9
  362.  19h     P              1Ah     [              4Ah      KP-
  363.  10h     Q              1Bh     ]              4Bh      KP4
  364.  13h     R              1Ch    CR              4Ch      KP5
  365.  1Fh     S              2Ah   L-SHIFT          4Dh      KP6
  366.  14h     T              39h     SPACE          4Eh      KP+
  367.  16h     U              36h   R-SHIFT          4Fh      KP1
  368.  2Fh     V              33h     ,              50h      KP2
  369.  11h     W              34h     .              51h      KP3
  370.  2Dh     X              35h     /              52h      KP0   
  371.  15h     Y                                     53h      DEL 
  372.  2Ch     Z
  373.  
  374.  
  375.  
  376. Appendix C
  377. KEYBOARD SHIFT STATE MASK CODES
  378.  
  379.   The following is a list of values which can used with the /S option to 
  380. specify a hot key shift state code.  The default value for this option is 
  381. 8 (Alt key held down).  You may numerically add values to create multiple 
  382. shift conditions.  For example, "/S09" would be used to specify both the 
  383. Right shift and Alt key held down when the hot key is pressed.  Only the 
  384. four lower bits of the shift mask are used.
  385.  
  386.  
  387.    Value          Shift State
  388.  
  389.      0          No shift key needed
  390.      1          Right shift held down
  391.      2          Left shift held down
  392.      4          Ctrl key held down
  393.      8          Alt key held down
  394.